package com.example.spring_mybatis.controller;

import com.example.spring_mybatis.model.UserInfo;
import com.example.spring_mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025/6/17
 * Time: 21:33
 */
@RequestMapping("/user")
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/getUserAll1")
    public List<UserInfo> getUserAll1() {
        return userService.getUserInfoAll1();
    }

    @RequestMapping("/getUserDemo1")
    public List<UserInfo> getUserDemo1(Integer deleteFlag) {
        return userService.getUserInfoADemo1(deleteFlag);
    }

    @RequestMapping("/login")
    public Boolean login(String userName,String password){
        List<UserInfo> userinfo = userService.loginByUserNameOrPassword(userName,password);
        if (userinfo == null || !userinfo.get(0).getPassword().equals(password)){
            return false;
        }
        return true;
    }
}
